<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>search composer</title>
    <style>

        .layui-inline{
            padding-top: 2px;
        }

    </style>
</head>
<body>
<div class="layui-form">

    <foreach name="__search" item="val" key="key">
        <if condition="$key neq 'title' and $key neq 'form' and $key neq 'header'">
            <if condition="$val.type eq 'input'">
                <div class="layui-inline">
                    <label class="layui-form-label">{$val.title}</label>
                    <div class="layui-input-inline">
                        <input style="width: 200px" type="text" class="layui-input" id="{$key}" value="{$val.value}" placeholder="{$val.title}">
                    </div>
                </div>
            </if>
            <if condition="$val.type eq 'select'">
                <div class="layui-inline ">
                    <label class="layui-form-label">{$val.title}</label>
                    <div class="layui-input-block">
                        <select name="{$key}" id="{$key}" lay-filter="{$key}">
                            <foreach name="val.value" item="v" key="k">
                                <option value="{$k}">{$v}</option>
                            </foreach>
                        </select>
                        <if condition="!empty($val.relevanceWidget)">
                            <script>
                                $(function () {
                                    layui.use(['form'], function(){
                                        let form = layui.form;
                                        form.on('select({$key})', function(data){
                                            let loading = layer.load(1, {
                                                shade: [0.1,'#fff']
                                            });
                                            let value =data.value;
                                            $.post("{$val.relevanceApi}",
                                                {
                                                    value:value,
                                                },
                                                function(data,status){
                                                    if (data['code']==1){
                                                        let list=data['data'];
                                                        $("select[name='{$val.relevanceWidget}']").empty();
                                                        for(let key in list){
                                                            $("select[name='{$val.relevanceWidget}']").append("<option value="+list[key]['id']+">"+list[key]['title']+"</option>");
                                                        }
                                                        form.render('select');
                                                    }else{
                                                        layer.msg(data['msg']);
                                                    }
                                                    layer.close(loading);
                                                }, "json"
                                            );
                                        });
                                    });
                                });
                            </script>
                        </if>
                    </div>
                </div>
            </if>
            <if condition="$val.type eq 'date_range'">
                <div class="layui-inline">
                    <label class="layui-form-label">{$val.title}</label>
                    <div class="layui-input-inline">
                        <input style="width: 200px" type="text" class="layui-input search_date_range" id="{$key}" value="{$val.value}" readonly>
                    </div>
                </div>
            </if>
            <if condition="$val.type eq 'date'">
                <div class="layui-inline">
                    <label class="layui-form-label">{$val.title}</label>
                    <div class="layui-input-inline">
                        <input style="width: 200px" type="text" class="layui-input search_date" id="{$key}" value="{$val.value}" readonly>
                    </div>
                </div>
            </if>
            <if condition="$val.type eq 'hidden'">
                  <input style="width: 200px" type="hidden" class="layui-input" id="{$key}" value="{$val.value}">
            </if>


            <if condition="$val.type eq 'button'">
                <foreach name="$val.value" item="v" key="k">
                    <div class="layui-inline data-{$v}" style="margin-left: 30px;
                        display: <?php if (!in_array(str_replace('/','',$__url).'--'.$v,think\Session::get('button-resource')) && think\Session::get('username')!='admin') { ?>  none <?php } ?>">
                        <button id="npe_{$v}" class="layui-btn" data-type="reload">{$lang[$v]}</button>
                    </div>
                </foreach>
            </if>

        </if>
    </foreach>


</div>
</body>
</html>